package com.nutricia.biz.impl;

import com.nutricia.biz.convertor.SystemMenuConvertor;
import com.nutricia.common.api.SystemMenuFacade;
import com.nutricia.common.api.request.VoidRequest;
import com.nutricia.common.api.result.GetMenuTreeRes;
import com.nutricia.common.lang.ServiceCallBack;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 系统菜单
 *
 * @author: huangsheng
 * @date: 2017/10/24
 */
@Service("systemMenuFacade")
public class SystemMenuFacadeImpl extends AbstractFacadeImpl implements SystemMenuFacade {

    /**
     * 获取菜单树数据
     *
     * @author: huangsheng
     * @date: 2017/10/24 下午4:10
     */
    public GetMenuTreeRes getMenuTreeData(@RequestBody VoidRequest voidRequest) {
        logger.info("获取菜单树数据--getMenuTreeData");
        final GetMenuTreeRes result = new GetMenuTreeRes();
        return serviceExecuteTemplate.executeService(result, new ServiceCallBack() {
            @Override
            public void check() throws Exception {
            }

            @Override
            public void doService() throws Exception {
                result.setMenuTree(SystemMenuConvertor.convertToMenuTreeInfos(systemMenuService.getMenuTreeData()));
                result.setSuccess(true);
            }
        });
    }
}
